#include <stdio.h>
#include <iostream>

using namespace std;

#include "../Puffer/Buffer.h"
#include "Scanner.h"
#include "Token.h"
#include "Output.h"

// program entry point
int main(int argc, char* argv[]) {
	// check arguments
	if (argc != 3) {
		fprintf(stderr, "Usage: %s INPUTFILE OUTPUTFILE\n", argv[0]);
		return EXIT_FAILURE;
	}

	// prepare buffer
	Buffer buffer;
	if (!buffer.init(argv[1], argv[2])) {
		puts("Cannot initialize Buffer");
		return EXIT_FAILURE;
	}

	// prepare scanner and token
	Scanner* scanner = new ScannerImp(buffer);
	Token outputToken;

	// Additional () to avoid warnings
	while ((scanner->nextToken(outputToken))) {
		output(buffer, outputToken); // Print Token
	}

	// clean up
	delete scanner;

	puts("the end");

	return EXIT_SUCCESS;
}
